<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
  public function up()
  {
    Schema::create('locales', function (Blueprint $table) {
      $table->id();
      $table->bigInteger('country_id')->unsigned();
      $table->bigInteger('language_id')->unsigned();
      $table->string('code')->unique();
      $table->string('name');
      $table->boolean('active')->default(true);
      $table->timestamps();
      // Foreign keys constraints
      $table->foreign('country_id')->references('id')->on('countries')->onDelete('restrict');
      $table->foreign('language_id')->references('id')->on('languages')->onDelete('restrict');
    });
  }

  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
    Schema::dropIfExists('locales');
  }
};
